<%@ page import="java.util.List" %>
<%@ page import="pojo.QueryOrder" %>
<%--
  Created by IntelliJ IDEA.
  User: zkt
  Date: 2023/11/22
  Time: 10:52
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
    <head>
        <meta charset="UTF-8">
        <link rel="stylesheet" href="./css/bootstrap.min.css">
        <link rel="stylesheet" href="./css/administer.css">
        <script src="./js/jquery-3.7.1.min.js"></script>
        <script src="./js/bootstrap.min.js"></script>

        <title>查看订单</title>
    <body>
        <div class="container">
            <div class="panel panel-primary">
                <div class="panel-heading">
                    <h3 class="panel-title">订单查询</h3>
                </div>
                <div class="panel-body">
                    <form class="form" action="/orderQuery" method="get">
                        <div class="form-item">
                            <div class="text">账号</div>
                            <input type="text" name="account" class="input input-1" value="${map.get('account')}"
                                   placeholder="请输入账号">
                            <div class="text">课程名称</div>
                            <input type="text" name="course" class="input input-1" value="${map.get('name')}"
                                   placeholder="请输入课程名称">
                            <div class="text">年</div>
                            <input type="text" name="year" class="input input-2" value="${map.get('year')}">
                            <div class="text">月</div>
                            <input type="text" name="month" class="input input-2" value="${map.get('month')}">
                            <div class="text">日</div>
                            <input type="text" name="day" class="input input-2" value="${map.get('day')}">
                            <div class="text">支付状态</div>
                            <select name="status" class="input input-3">
                                <option value="-1" ${map.get('status') == '-1' ? 'selected' : ''}>--请选择--&nbsp;</option>
                                <option value="0" ${map.get('status') == '0' ? 'selected' : ''}>待支付&nbsp;</option>
                                <option value="1" ${map.get('status') == '1' ? 'selected' : ''}>已支付&nbsp;</option>
                            </select>
                            <input type="hidden" name="page" value="1">
                        </div>
                        <div>
                            <button type="submit" class="btn btn-primary" style="margin-right: 2rex">查询
                            </button>
                            <a type="reset" href="/orderAll" class="btn bg-primary">重置
                            </a>
                        </div>
                    </form>
                </div>
            </div>
            <div class="shadow">
                <div class="table-responsive">
                    <table class="table table-hover table-striped">
                        <thead class="color">
                        <tr>
                            <th>课程名</th>
                            <th>用户账号</th>
                            <th>金额</th>
                            <th>订单日期</th>
                            <th>支付状态</th>
                        </tr>
                        </thead>
                        <tbody>
                        <%
                            List<QueryOrder> orderList = (List<QueryOrder>) request.getSession().getAttribute("orderList");
                            if (orderList != null) {
                                for (QueryOrder order : orderList) {
                        %>
                        <tr>
                            <td><%=order.getName()%>
                            </td>
                            <td><%=order.getAccount()%>
                            </td>
                            <td><%=order.getPrice()%>
                            </td>
                            <td><%=order.getDate()%>
                            </td>
                            <td><%=order.getStatus()%>
                            </td>
                        </tr>
                        <%
                                }
                            }
                        %>
                        </tbody>
                    </table>
                </div>
            </div>

            <div class="foot">
                <%
                    int size = (int) request.getSession().getAttribute("size");
                %>
                <div style="line-height: 100%">
                    每页&nbsp;<b>10</b>&nbsp;条&nbsp;&nbsp;&nbsp;共&nbsp;<b><%=size%>
                </b>&nbsp;条
                </div>
                <div class="foot-button">
                    <a class="btn btn-default foot-item" type="button" href="/orderPgUp">上一页
                    </a>
                    <%
                        int active = (int) request.getSession().getAttribute("active");
                        int pages = ((size - 1) / 10) + 1;
                        for (int i = 1; i <= pages; i++) {

                    %>
                    <a class="btn btn-default
                    <%
                        if (i == active){
                    %>
                    active
                    <%
                        }
                    %>
                     foot-item" type="button" href="/orderQuery?page=<%=i%>"><%=i%>
                    </a>
                    <%
                        }
                    %>
                    <a class="btn btn-default foot-item" type="button" href="/orderPgDn">下一页
                    </a>
                </div>
            </div>
        </div>
    </body>
</html>
